package com.easylinkin.sm.controller;

import com.easylinkin.sm.constant.LogConstant.Module;
import com.easylinkin.sm.entity.Feedback;
import com.easylinkin.sm.service.FeedbackService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.boot.data.CrudControllerSupport;
import site.morn.boot.rest.RestPage;
import site.morn.log.OperateGroup;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;
import site.morn.validate.group.Search;

/**
 * 意见反馈控制器
 *
 * @author yezhihao
 * @since develop,2019/8/19
 */
@Api(tags = "意见反馈")
@OperateGroup(value = "feedback", args = Module.FEEDBACK)
@RestController("FeedbackController")
@RequestMapping("/feedback")
public class FeedbackController extends CrudControllerSupport<Feedback, Long, FeedbackService> {

  /**
   * 分页搜索意见反馈
   *
   * @return 意见反馈
   *
   */
  @ApiOperation("分页搜索意见反馈")
  @PostMapping("/getFeedback")
  public RestMessage getFeedback(@Validated({Search.class}) @RequestBody RestPage<Feedback> restPage) {
    return RestBuilders.successMessage(service().getFeedback(restPage));
  }

  /**
   * 意见反馈详情
   *
   * @return 意见反馈
   *
   */
  @ApiOperation("意见反馈详情")
  @GetMapping("/getDetails")
  public RestMessage getDetails(Long id) {
    return RestBuilders.successMessage(service().getDetails(id));
  }

}
